import type { RouteRecordRaw } from 'vue-router'
import { createRouter, createWebHashHistory } from 'vue-router'

class RouteRecord {
  [key: string]: RouteRecordRaw
}
const routerList = import.meta.glob<RouteRecord>('./modules/*.ts', { eager: true })
const routerArray: RouteRecordRaw[] = []
Object.keys(routerList).forEach((item) => {
  Object.keys(routerList[item]).forEach((key: string) => {
    routerArray.push(routerList[item][key])
  })
})

const router = createRouter({
  history: createWebHashHistory(),
  routes: routerArray
})

export default router
